package com.qzimp.fujiancuo.controller;

import com.qzimp.fujiancuo.entity.Temple;
import com.qzimp.fujiancuo.service.TempleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/temples")
public class TempleController {

    @Autowired
    private TempleService templeService;

    @GetMapping("/{id}")
    public Temple getTemple(@PathVariable Long id) {
        return templeService.findById(id);
    }

    @GetMapping
    public List<Temple> getAllTemples() {
        return templeService.findAll();
    }

    @PostMapping
    public void addTemple(@RequestBody Temple temple) {
        templeService.addTemple(temple);
    }

    @PutMapping
    public void updateTemple(@RequestBody Temple temple) {
        templeService.updateTemple(temple);
    }

    @DeleteMapping("/{id}")
    public void deleteTemple(@PathVariable Long id) {
        templeService.deleteTemple(id);
    }
}